package com.feedback.c;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import com.feedback.a.a;
import com.feedback.a.b;
import com.feedback.a.d;
import com.feedback.a.e;
import com.feedback.b.d;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class a extends Thread
{
  private static ExecutorService b = Executors.newFixedThreadPool(3);
  private Context a;

  public a(Context paramContext)
  {
    this.a = paramContext;
  }

  public void run()
  {
    label36: String str1;
    Iterator localIterator2;
    int i;
    ArrayList localArrayList = new ArrayList();
    SharedPreferences localSharedPreferences = this.a.getSharedPreferences("feedback", 0);
    Iterator localIterator1 = localSharedPreferences.getAll().keySet().iterator();
    do
    {
      if (!(localIterator1.hasNext()))
      {
        localIterator2 = localArrayList.iterator();
        i = 0;
        if (localIterator2.hasNext())
          break;
        if (i != 0)
        {
          Intent localIntent = new Intent().setAction("postFeedbackFinished");
          this.a.sendBroadcast(localIntent);
        }
        return;
      }
      str1 = localSharedPreferences.getString((String)localIterator1.next(), null);
    }
    while ((d.a(str1)) || (str1.indexOf("fail") == -1));
    try
    {
      localArrayList.add(new d(new JSONArray(str1)));
    }
    catch (Exception localException)
    {
      d locald;
      com.feedback.a.a locala;
      do
      {
        break label36:
        locald = (d)localIterator2.next();
      }
      while ((locald.b == e.d) || (locald.b == e.a));
      Iterator localIterator3 = locald.f.iterator();
      int j = i;
      int k = -1;
      do
      {
        while (!(localIterator3.hasNext()))
          i = j;
        locala = (com.feedback.a.a)localIterator3.next();
        ++k;
      }
      while (locala.g != b.b);
      String str2 = localSharedPreferences.getString(locald.c, null);
      try
      {
        JSONArray localJSONArray = new JSONArray(str2);
        localJSONArray.put(k, locala.h.put("state", b.d));
        localSharedPreferences.edit().putString(locald.c, localJSONArray.toString()).commit();
        c localc = new c(locala.h, this.a);
        b.submit(localc);
        j = 1;
      }
      catch (JSONException localJSONException)
      {
      }
    }
  }
}